ActionController::Routing::Routes.draw do |map|
  # The priority is based upon order of creation: first created -> highest priority.

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
  
  # Sample resource route with more complex sub-resources
  #   map.resources :products do |products|
  #     products.resources :comments
  #     products.resources :sales, :collection => { :recent => :get }
  #   end

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  # map.root :controller => "welcome"

  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing or commenting them out if you're using named routes and resources.

  map.root :controller => 'homes',:action => 'show'

  map.resources :homes,
    :valleyers,
    :meets,
    :oldmeets,
    :documents,
    :photos,
    :show_logs,
    :show_reships,
    :albums,
    :friend_ships,
    :back_stages,
    :members

  map.namespace :test_field do |test_field|
    test_field.resources :photos
  end

  map.namespace :auto_complete do |auto_complete|
    auto_complete.resources :document_types,
      :albums
  end

  map.namespace :homes do |homes|
    homes.namespace :show do |show|
      show.resources :sessions
    end
  end

  #个人主页,个人资料,个人日志,个人转载,个人头像,个人相册
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.resources :homes,
        :personal_infos,
        :logs,
        :transit_cargos,
        :logos,
        :albums
    end
  end

  #个人->主页
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :homes do |homes|
        homes.namespace :show do |show|
          show.resources :moods,
            :logs,
            :reships,
            :posts,
            :albums,
            :friends
        end
      end
    end
  end

  #个人资料->个人信息,公司信息
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :personal_infos do |personal_infos|
        personal_infos.namespace :show do |show|
          show.resources :base_infos,
            :company_infos,
            :posts,
            :friends
        end
      end
    end
  end

  #个人->日志管理
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :logs do |logs|
        logs.namespace :show do |show|
          show.resources :posts,
            :articles,
            :documet_types
        end
      end
    end
  end

  #个人->转载管理
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :transit_cargos do |transit_cargos|
        transit_cargos.namespace :show do |show|
          show.resources :posts,
            :reships,
            :documet_types
        end
      end
    end
  end

  #个人->相册管理
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :albums do |albums|
        albums.namespace :show do |show|
          show.resources :friends,
            :photos
        end
      end
    end
  end

  #个人->相片->列表
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :albums do |albums|
        albums.namespace :show do |show|
          show.namespace :photos do |photos|
            photos.namespace :show do |show|
              show.resources :entries
            end
          end
        end
      end
    end
  end

  #相册评论
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :albums do |albums|
        albums.namespace :show do |show|
          show.namespace :photos do |photos|
            photos.namespace :show do |show|
              show.namespace :entries do |entries|
                entries.namespace :show do |show|
                  show.resources :posts
                end
              end
            end
          end
        end
      end
    end
  end

  #个人->相片->浏览
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :albums do |albums|
        albums.namespace :show do |show|
          show.namespace :photos do |photos|
            photos.namespace :show do |show|
              show.resources :scans
            end
          end
        end
      end
    end
  end

  #相片评论
  map.namespace :valleyers do |valleyers|
    valleyers.namespace :show do |show|
      show.namespace :albums do |albums|
        albums.namespace :show do |show|
          show.namespace :photos do |photos|
            photos.namespace :show do |show|
              show.namespace :scans do |scans|
                scans.namespace :show do |show|
                  show.resources :posts
                end
              end
            end
          end
        end
      end
    end
  end

  #文档
  map.namespace :documents do |documents|
    documents.namespace :show do |show|
      show.resources :homes,
        :logs,
        :reships,
        :documet_types,
        :albums
    end
  end
  
  #文档->主页
  map.namespace :documents do |documents|
    documents.namespace :show do |show|
      show.namespace :homes do |homes|
        homes.namespace :show do |show|
          show.resources :logs,
            :reships,
            :documet_types
        end
      end
    end
  end

  #文档->日志
  map.namespace :documents do |documents|
    documents.namespace :show do |show|
      show.namespace :logs do |logs|
        logs.namespace :show do |show|
          show.resources :documet_types
        end
      end
    end
  end
  
  #文档->转载
  map.namespace :documents do |documents|
    documents.namespace :show do |show|
      show.namespace :reships do |reships|
        reships.namespace :show do |show|
          show.resources :documet_types
        end
      end
    end
  end

  #日志浏览的评论
  map.namespace :show_logs do |show_logs|
    show_logs.namespace :show do |show|
      show.resources :posts
    end
  end

  #转载浏览的评论
  map.namespace :show_reships do |show_reships|
    show_reships.namespace :show do |show|
      show.resources :posts
    end
  end

  #后台管理
  map.namespace :back_stages do |back_stages|
    back_stages.namespace :show do |show|
      show.resources :admins,
        :logs,
        :reships,
        :albums
    end
  end

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end
